﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Admin_AddSlider : System.Web.UI.Page
{
    SliderController sliderController = new SliderController();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Slider s = new Slider();
        s.Title = txtTitle.Text;
        s.Url = txtUrl.Text;
        s.Image = slider_value.Value;
        s.Order = Convert.ToInt32(txtOrder.Text);
        if(ddlStatus.SelectedIndex==0)
        {
            s.Status = true;
        }
        else
        {
            s.Status = false;
        }
        s.DateStart = DateTime.Now;
        int i = sliderController.Insert(s);
        if(i>0)
        {
            Response.Write("<script>alert('Thêm slider thành công')</script>");
            txtTitle.Text = "";
            txtOrder.Text = "";
            ddlStatus.SelectedIndex = 0;
            txtUrl.Text = "";
            slider_value.Value = "";
        }
        else
        {
            Response.Write("<script>alert('Thêm slider gặp lỗi')</script>");
        }
    }
}